﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Xml.Linq;

namespace RoccaStore.Utils
{
    public class HttpUtils
    {
        public static string GenerateContentType(string extension)
        {
            XDocument x = XDocument.Load(HttpContext.Current.Server.MapPath("~/App_Data/content_types.xml"));
            var contentType = (from p in x.Descendants("contentType")
                               where extension.Contains(p.Element("extension").Value)
                               select p.Element("name")).FirstOrDefault();

            string type = string.Empty;

            if (contentType == null)
                type = "multipart/mixed";
            else
                type = contentType.Value;

            return type;
        }


    }
}
